@metaphi-ai/hum 0.2.40 → 0.2.41

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
@@ -89291,6 +89291,38 @@ function trustedPython(env3 = process.env, runImpl = run) {
89291
89291
  const p = r && r.status === 0 ? String(r.stdout).trim().split(/\r?\n/).pop() : "";
89292
89292
  return /^[a-z]:\\.+\\python(w)?\.exe$/i.test(p) ? p : null;
89293
89293
  }
89294
+ function signedPython(env3 = process.env, { say = () => {
89295
+ }, runImpl = run, platform: platform2 = process.platform } = {}) {
89296
+ if (platform2 !== "win32") return null;
89297
+ const dir = path.join(humHome(env3), "python", SIGNED_PYTHON.version);
89298
+ const python = path.join(dir, "tools", "python.exe");
89299
+ if (fs3.existsSync(python)) return python;
89300
+ say(`fetching Python ${SIGNED_PYTHON.version} from python.org (signed; your machine's policy trusts it) \u2026`);
89301
+ const part = `${dir}.part`, zip = `${dir}.zip`;
89302
+ const q = (s) => `'${s.replace(/'/g, "''")}'`;
89303
+ const script = [
89304
+ "$ErrorActionPreference = 'Stop'",
89305
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12",
89306
+ `(New-Object Net.WebClient).DownloadFile(${q(SIGNED_PYTHON.url)}, ${q(zip)})`,
89307
+ `$f = [IO.File]::OpenRead(${q(zip)}); try { $h = ([BitConverter]::ToString([Security.Cryptography.SHA256]::Create().ComputeHash($f)) -replace '-', '').ToLower() } finally { $f.Dispose() }`,
89308
+ `if ($h -ne ${q(SIGNED_PYTHON.sha256)}) { throw 'checksum mismatch' }`,
89309
+ `if ([IO.Directory]::Exists(${q(part)})) { [IO.Directory]::Delete(${q(part)}, $true) }`,
89310
+ "[void][Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')",
89311
+ `[IO.Compression.ZipFile]::ExtractToDirectory(${q(zip)}, ${q(part)})`,
89312
+ `[IO.Directory]::Move(${q(part)}, ${q(dir)})`
89313
+ ].join("; ");
89314
+ fs3.mkdirSync(path.dirname(dir), { recursive: true });
89315
+ const r = runImpl("powershell", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", script]);
89316
+ try {
89317
+ fs3.unlinkSync(zip);
89318
+ } catch {
89319
+ }
89320
+ if (!(r && r.status === 0) || !fs3.existsSync(python)) {
89321
+ say(`could not fetch it (${String(r && (r.stderr || r.stdout) || "powershell failed").trim().split(/\r?\n/)[0]})`);
89322
+ return null;
89323
+ }
89324
+ return python;
89325
+ }
89294
89326
  function sslBlocked(env3 = process.env, version = MINE, runImpl = run) {
89295
89327
  const r = runImpl(corePython(env3, version), ASK_SSL);
89296
89328
  if (r && r.status === 0) return null;
@@ -89331,7 +89363,7 @@ function installCore(version, { env: env3 = process.env, say = (m) => console.lo
89331
89363
  fs3.unlinkSync(stampPath(env3, version));
89332
89364
  } catch {
89333
89365
  }
89334
- const trusted = trustedPython(env3, runImpl);
89366
+ const trusted = trustedPython(env3, runImpl) || signedPython(env3, { say, runImpl });
89335
89367
  const makeVenv = (clear) => (runImpl(u, ["venv", "--quiet", "--python", trusted || "3.12", ...clear ? ["--clear"] : [], dir], { stdio: "inherit" }) || {}).status === 0;
89336
89368
  const pipIn = () => (runImpl(u, ["pip", "install", "--quiet", "--refresh-package", "hum-cli", "--python", python, spec], { stdio: "inherit" }) || {}).status === 0;
89337
89369
  if (!fs3.existsSync(python) && !makeVenv(fs3.existsSync(dir))) return outcome(false, "uv venv failed");
@@ -89454,12 +89486,12 @@ function installVersion(version, { env: env3 = process.env, say = (m) => console
89454
89486
  return { ok: false, error: e && e.message ? e.message : String(e) };
89455
89487
  }
89456
89488
  }
89457
- var win, MINE, npmFix, NPM_FIX, humHome, versionsDir, versionDir, pkgDir, coreDir, corePython, readyFile, entryFile, stampPath, statePath, isVersion, newer, run, ASK_VERSION, ASK_SSL, sslAdvice, readInstallState, writeInstallState, pause;
89489
+ var win, MINE, npmFix, NPM_FIX, humHome, versionsDir, versionDir, pkgDir, coreDir, corePython, readyFile, entryFile, stampPath, statePath, isVersion, newer, run, ASK_VERSION, SIGNED_PYTHON, ASK_SSL, sslAdvice, readInstallState, writeInstallState, pause;
89458
89490
  var init_install = __esm({
89459
89491
  "src/install.js"() {
89460
89492
  init_define_HUM_CORE_SUBS();
89461
89493
  win = process.platform === "win32";
89462
- MINE = true ? "0.2.40" : "";
89494
+ MINE = true ? "0.2.41" : "";
89463
89495
  npmFix = (version = "") => `npm i -g @metaphi-ai/hum@${version || "latest"} --foreground-scripts`;
89464
89496
  NPM_FIX = npmFix("latest");
89465
89497
  humHome = (env3 = process.env) => env3.HUM_HOME || path.join(os3.homedir(), ".hum");
@@ -89482,8 +89514,13 @@ var init_install = __esm({
89482
89514
  };
89483
89515
  run = (cmd, args2, opts = {}) => spawnSync(cmd, args2, { encoding: "utf8", windowsHide: true, ...opts });
89484
89516
  ASK_VERSION = ["-I", "-c", "import hum; print(hum.__version__)"];
89517
+ SIGNED_PYTHON = {
89518
+ version: "3.12.10",
89519
+ url: "https://api.nuget.org/v3-flatcontainer/python/3.12.10/python.3.12.10.nupkg",
89520
+ sha256: "0eb85c2dfccccf1b17352de4c397f69194035b7d37149eacc16f1147d93de3b8"
89521
+ };
89485
89522
  ASK_SSL = ["-I", "-c", "import ssl"];
89486
- sslAdvice = (env3, version) => `the machine's application control blocked Python's OpenSSL DLL in ${coreDir(env3, version)}; install Python 3.12 from python.org (Microsoft signs it), then run ${npmFix(version)}`;
89523
+ sslAdvice = (env3, version) => `the machine's application control blocked Python's OpenSSL DLL in ${coreDir(env3, version)}; install Python 3.12 from python.org (signed by the Python Software Foundation), then run ${npmFix(version)}`;
89487
89524
  readInstallState = (env3 = process.env) => {
89488
89525
  try {
89489
89526
  return JSON.parse(fs3.readFileSync(statePath(env3), "utf8"));
@@ -89805,10 +89842,10 @@ function clientEnv() {
89805
89842
  platform: process.platform,
89806
89843
  arch: process.arch,
89807
89844
  terminal: process.env.TERM_PROGRAM || (process.env.WT_SESSION ? "Windows Terminal" : process.env.TERM || ""),
89808
- tui: true ? "0.2.40" : ""
89845
+ tui: true ? "0.2.41" : ""
89809
89846
  };
89810
89847
  }
89811
- function startFailure(failures, { npm = /^(node|bun)(\.exe)?$/i.test(String(process.execPath).split(/[\\/]/).pop()), platform: platform2 = process.platform, version = true ? "0.2.40" : "" } = {}) {
89848
+ function startFailure(failures, { npm = /^(node|bun)(\.exe)?$/i.test(String(process.execPath).split(/[\\/]/).pop()), platform: platform2 = process.platform, version = true ? "0.2.41" : "" } = {}) {
89812
89849
  const refused = failures.find((f) => f.error && f.error.code !== "ENOENT");
89813
89850
  const fix = npm ? npmFix(version) : updateCommand({ kind: "native" }, platform2);
89814
89851
  if (!refused) {
@@ -90394,7 +90431,7 @@ async function diagnose({
90394
90431
  checks.push(check2(
90395
90432
  "fail",
90396
90433
  `${running.bin} cannot load OpenSSL (${why}); on a managed Windows machine that is the application control policy refusing the DLL`,
90397
- isWin(platform2) ? `install Python 3.12 from python.org (Microsoft signs it), then run ${npmFix2(mine)}` : npmFix2(mine)
90434
+ isWin(platform2) ? `install Python 3.12 from python.org (signed by the Python Software Foundation), then run ${npmFix2(mine)}` : npmFix2(mine)
90398
90435
  ));
90399
90436
  }
90400
90437
  }
@@ -91323,7 +91360,7 @@ var after = (ms, fn) => {
91323
91360
 
91324
91361
  // src/app.jsx
91325
91362
  var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
91326
- var MINE2 = true ? "0.2.40" : "";
91363
+ var MINE2 = true ? "0.2.41" : "";
91327
91364
  var fmtDur = (s) => s < 60 ? `${Math.max(1, Math.round(s))}s` : `${Math.floor(s / 60)}m ${Math.round(s % 60)}s`;
91328
91365
  var plural = (n, w) => `${n} ${w}${n === 1 ? "" : "s"}`;
91329
91366
  var shortSession = (name) => (name || "").replace(/\.jsonl$/, "");
@@ -93796,7 +93833,7 @@ init_install();
93796
93833
  await init_theme();
93797
93834
  var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
93798
93835
  import { spawnSync as spawnSync6 } from "node:child_process";
93799
- var MINE3 = true ? "0.2.40" : "0.0.0";
93836
+ var MINE3 = true ? "0.2.41" : "0.0.0";
93800
93837
  var layout = installLayout();
93801
93838
  function completeInstall() {
93802
93839
  if (layout.kind !== "npm" || !needsInstall(MINE3)) return;
package/dist/install.mjs CHANGED
@@ -69,6 +69,43 @@ function trustedPython(env = process.env, runImpl = run) {
69
69
  const p = r && r.status === 0 ? String(r.stdout).trim().split(/\r?\n/).pop() : "";
70
70
  return /^[a-z]:\\.+\\python(w)?\.exe$/i.test(p) ? p : null;
71
71
  }
72
+ var SIGNED_PYTHON = {
73
+ version: "3.12.10",
74
+ url: "https://api.nuget.org/v3-flatcontainer/python/3.12.10/python.3.12.10.nupkg",
75
+ sha256: "0eb85c2dfccccf1b17352de4c397f69194035b7d37149eacc16f1147d93de3b8"
76
+ };
77
+ function signedPython(env = process.env, { say = () => {
78
+ }, runImpl = run, platform = process.platform } = {}) {
79
+ if (platform !== "win32") return null;
80
+ const dir = path.join(humHome(env), "python", SIGNED_PYTHON.version);
81
+ const python = path.join(dir, "tools", "python.exe");
82
+ if (fs.existsSync(python)) return python;
83
+ say(`fetching Python ${SIGNED_PYTHON.version} from python.org (signed; your machine's policy trusts it) \u2026`);
84
+ const part = `${dir}.part`, zip = `${dir}.zip`;
85
+ const q = (s) => `'${s.replace(/'/g, "''")}'`;
86
+ const script = [
87
+ "$ErrorActionPreference = 'Stop'",
88
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12",
89
+ `(New-Object Net.WebClient).DownloadFile(${q(SIGNED_PYTHON.url)}, ${q(zip)})`,
90
+ `$f = [IO.File]::OpenRead(${q(zip)}); try { $h = ([BitConverter]::ToString([Security.Cryptography.SHA256]::Create().ComputeHash($f)) -replace '-', '').ToLower() } finally { $f.Dispose() }`,
91
+ `if ($h -ne ${q(SIGNED_PYTHON.sha256)}) { throw 'checksum mismatch' }`,
92
+ `if ([IO.Directory]::Exists(${q(part)})) { [IO.Directory]::Delete(${q(part)}, $true) }`,
93
+ "[void][Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')",
94
+ `[IO.Compression.ZipFile]::ExtractToDirectory(${q(zip)}, ${q(part)})`,
95
+ `[IO.Directory]::Move(${q(part)}, ${q(dir)})`
96
+ ].join("; ");
97
+ fs.mkdirSync(path.dirname(dir), { recursive: true });
98
+ const r = runImpl("powershell", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", script]);
99
+ try {
100
+ fs.unlinkSync(zip);
101
+ } catch {
102
+ }
103
+ if (!(r && r.status === 0) || !fs.existsSync(python)) {
104
+ say(`could not fetch it (${String(r && (r.stderr || r.stdout) || "powershell failed").trim().split(/\r?\n/)[0]})`);
105
+ return null;
106
+ }
107
+ return python;
108
+ }
72
109
  var ASK_SSL = ["-I", "-c", "import ssl"];
73
110
  function sslBlocked(env = process.env, version = MINE, runImpl = run) {
74
111
  const r = runImpl(corePython(env, version), ASK_SSL);
@@ -76,7 +113,7 @@ function sslBlocked(env = process.env, version = MINE, runImpl = run) {
76
113
  const text = String(r && (r.stderr || r.stdout) || "ssl did not import").trim().split(/\r?\n/).filter(Boolean).pop() || "ssl did not import";
77
114
  return text;
78
115
  }
79
- var sslAdvice = (env, version) => `the machine's application control blocked Python's OpenSSL DLL in ${coreDir(env, version)}; install Python 3.12 from python.org (Microsoft signs it), then run ${npmFix(version)}`;
116
+ var sslAdvice = (env, version) => `the machine's application control blocked Python's OpenSSL DLL in ${coreDir(env, version)}; install Python 3.12 from python.org (signed by the Python Software Foundation), then run ${npmFix(version)}`;
80
117
  var readInstallState = (env = process.env) => {
81
118
  try {
82
119
  return JSON.parse(fs.readFileSync(statePath(env), "utf8"));
@@ -125,7 +162,7 @@ function installCore(version, { env = process.env, say = (m) => console.log(`hum
125
162
  fs.unlinkSync(stampPath(env, version));
126
163
  } catch {
127
164
  }
128
- const trusted = trustedPython(env, runImpl);
165
+ const trusted = trustedPython(env, runImpl) || signedPython(env, { say, runImpl });
129
166
  const makeVenv = (clear) => (runImpl(u, ["venv", "--quiet", "--python", trusted || "3.12", ...clear ? ["--clear"] : [], dir], { stdio: "inherit" }) || {}).status === 0;
130
167
  const pipIn = () => (runImpl(u, ["pip", "install", "--quiet", "--refresh-package", "hum-cli", "--python", python, spec], { stdio: "inherit" }) || {}).status === 0;
131
168
  if (!fs.existsSync(python) && !makeVenv(fs.existsSync(dir))) return outcome(false, "uv venv failed");
@@ -277,6 +314,7 @@ export {
277
314
  ASK_VERSION,
278
315
  MINE,
279
316
  NPM_FIX,
317
+ SIGNED_PYTHON,
280
318
  chosenEntry,
281
319
  coreDir,
282
320
  corePython,
@@ -295,6 +333,7 @@ export {
295
333
  readInstallState,
296
334
  readyFile,
297
335
  readyVersions,
336
+ signedPython,
298
337
  sslAdvice,
299
338
  sslBlocked,
300
339
  trustedPython,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metaphi-ai/hum",
3
- "version": "0.2.40",
3
+ "version": "0.2.41",
4
4
  "description": "Hum: a self-improving coding agent for your terminal.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",