@metaphi-ai/hum 0.1.36 → 0.1.38

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
@@ -74600,6 +74600,18 @@ function installedVersion(env3 = process.env, runImpl = run) {
74600
74600
  }
74601
74601
  return v;
74602
74602
  }
74603
+ function trustedPython(env3 = process.env, runImpl = run) {
74604
+ if (!win) return null;
74605
+ const r = runImpl("py", ["-3.12", "-I", "-c", "import ssl, sys; print(sys.executable)"]);
74606
+ const p = r && r.status === 0 ? String(r.stdout).trim().split(/\r?\n/).pop() : "";
74607
+ return /^[a-z]:\\.+\\python(w)?\.exe$/i.test(p) ? p : null;
74608
+ }
74609
+ function sslBlocked(env3 = process.env, runImpl = run) {
74610
+ const r = runImpl(enginePython(env3), ASK_SSL);
74611
+ if (r && r.status === 0) return null;
74612
+ const text = String(r && (r.stderr || r.stdout) || "ssl did not import").trim().split(/\r?\n/).filter(Boolean).pop() || "ssl did not import";
74613
+ return text;
74614
+ }
74603
74615
  function needsInstall(version, { env: env3 = process.env, installed = () => installedVersion(env3), now = Date.now(), state = readInstallState(env3) } = {}) {
74604
74616
  if (!version || env3.HUM_ENGINE || env3.HUM_ENGINE_PORT) return false;
74605
74617
  if (installed() === version) return false;
@@ -74635,14 +74647,23 @@ function installEngine(version, { env: env3 = process.env, say = (m) => console.
74635
74647
  fs2.unlinkSync(stampPath(env3));
74636
74648
  } catch {
74637
74649
  }
74638
- if (!fs2.existsSync(python)) {
74639
- const args2 = ["venv", "--quiet", "--python", "3.12", ...fs2.existsSync(dir) ? ["--clear"] : [], dir];
74640
- if ((runImpl(u, args2, { stdio: "inherit" }) || {}).status !== 0) return outcome(false, "uv venv failed");
74641
- }
74642
- if ((runImpl(u, ["pip", "install", "--quiet", "--python", python, spec], { stdio: "inherit" }) || {}).status !== 0) return outcome(false, `uv pip install ${spec} failed`);
74643
- const got = importedVersion(env3, runImpl);
74650
+ const trusted = trustedPython(env3, runImpl);
74651
+ const makeVenv = (clear) => (runImpl(u, ["venv", "--quiet", "--python", trusted || "3.12", ...clear ? ["--clear"] : [], dir], { stdio: "inherit" }) || {}).status === 0;
74652
+ const pipIn = () => (runImpl(u, ["pip", "install", "--quiet", "--python", python, spec], { stdio: "inherit" }) || {}).status === 0;
74653
+ if (!fs2.existsSync(python) && !makeVenv(fs2.existsSync(dir))) return outcome(false, "uv venv failed");
74654
+ if (!pipIn()) return outcome(false, `uv pip install ${spec} failed`);
74655
+ let got = importedVersion(env3, runImpl);
74644
74656
  if (!got) return outcome(false, "hum did not import after the install");
74645
74657
  if (got !== version && !env3.HUM_ENGINE_SPEC) return outcome(false, `installed ${got}, wanted ${version}`, got);
74658
+ let blocked = sslBlocked(env3, runImpl);
74659
+ if (blocked && trusted) {
74660
+ say(`the policy here refuses the environment's OpenSSL (${blocked}); rebuilding it on ${trusted} \u2026`);
74661
+ if (makeVenv(true) && pipIn()) {
74662
+ got = importedVersion(env3, runImpl) || got;
74663
+ blocked = sslBlocked(env3, runImpl);
74664
+ }
74665
+ }
74666
+ if (blocked) return outcome(false, sslAdvice(env3, version));
74646
74667
  fs2.mkdirSync(dir, { recursive: true });
74647
74668
  fs2.writeFileSync(stampPath(env3), `${got}
74648
74669
  `);
@@ -74657,7 +74678,7 @@ function installEngine(version, { env: env3 = process.env, say = (m) => console.
74657
74678
  return outcome(false, e && e.message ? e.message : String(e));
74658
74679
  }
74659
74680
  }
74660
- var win, npmFix, NPM_FIX, humHome, engineDir, enginePython, stampPath, statePath, run, ASK_VERSION, readInstallState, writeInstallState;
74681
+ var win, npmFix, NPM_FIX, humHome, engineDir, enginePython, stampPath, statePath, run, ASK_VERSION, ASK_SSL, sslAdvice, readInstallState, writeInstallState;
74661
74682
  var init_install = __esm({
74662
74683
  "src/install.js"() {
74663
74684
  win = process.platform === "win32";
@@ -74670,6 +74691,8 @@ var init_install = __esm({
74670
74691
  statePath = (env3) => path.join(humHome(env3), "engine-install.json");
74671
74692
  run = (cmd, args2, opts = {}) => spawnSync(cmd, args2, { encoding: "utf8", windowsHide: true, ...opts });
74672
74693
  ASK_VERSION = ["-I", "-c", "import hum; print(hum.__version__)"];
74694
+ ASK_SSL = ["-I", "-c", "import ssl"];
74695
+ sslAdvice = (env3, version) => `the machine's application control blocked Python's OpenSSL DLL in ${engineDir(env3)}; install Python 3.12 from python.org (Microsoft signs it), then run ${npmFix(version)}`;
74673
74696
  readInstallState = (env3 = process.env) => {
74674
74697
  try {
74675
74698
  return JSON.parse(fs2.readFileSync(statePath(env3), "utf8"));
@@ -75838,7 +75861,7 @@ function runningVersion(candidates = engineCandidates(), opts = {}) {
75838
75861
  }
75839
75862
  return null;
75840
75863
  }
75841
- function startFailure(failures, { npm = /^(node|bun)(\.exe)?$/i.test(String(process.execPath).split(/[\\/]/).pop()), platform: platform2 = process.platform, version = true ? "0.1.36" : "" } = {}) {
75864
+ function startFailure(failures, { npm = /^(node|bun)(\.exe)?$/i.test(String(process.execPath).split(/[\\/]/).pop()), platform: platform2 = process.platform, version = true ? "0.1.38" : "" } = {}) {
75842
75865
  const refused = failures.find((f) => f.error && f.error.code !== "ENOENT");
75843
75866
  const fix = npm ? npmFix(version) : updateCommand({ kind: "native" }, platform2);
75844
75867
  if (!refused) {
@@ -76131,6 +76154,18 @@ async function diagnose({
76131
76154
  else if (running.version === mine) checks.push(check("ok", `${running.version} runs from ${running.where} (${running.bin})`));
76132
76155
  else if (env3.HUM_ENGINE) checks.push(check("fail", `${running.version} is what runs: HUM_ENGINE points at it (${env3.HUM_ENGINE}); you installed ${mine}`, "unset HUM_ENGINE"));
76133
76156
  else checks.push(check("fail", `${running.version} is what runs (${running.where}: ${running.bin}); you installed ${mine}`, layout2.kind === "npm" ? npmFix2(mine) : updateCommand(layout2, platform2)));
76157
+ if (running && running.args.includes("-m")) {
76158
+ const r = runImpl(running.bin, ["-I", "-c", "import ssl"], { encoding: "utf8", windowsHide: true, timeout: 2e4 });
76159
+ const said = String(r && (r.stderr || r.stdout) || "");
76160
+ if (!(r && r.status === 0) && /ssl|DLL/i.test(said)) {
76161
+ const why = said.trim().split(/\r?\n/).filter(Boolean).pop() || "ssl did not import";
76162
+ checks.push(check(
76163
+ "fail",
76164
+ `${running.bin} cannot load OpenSSL (${why}); on a managed Windows machine that is the application control policy refusing the DLL`,
76165
+ isWin(platform2) ? `install Python 3.12 from python.org (Microsoft signs it), then run ${npmFix2(mine)}` : npmFix2(mine)
76166
+ ));
76167
+ }
76168
+ }
76134
76169
  if (env3.HUM_ENGINE && running && running.version === mine) checks.push(check("warn", `HUM_ENGINE is set (${env3.HUM_ENGINE}): it decides what runs, ahead of any install`, "unset HUM_ENGINE"));
76135
76170
  if (layout2.kind === "npm") {
76136
76171
  const st = readInstallState(env3);
@@ -84541,7 +84576,7 @@ var input_default = MultilineInput;
84541
84576
 
84542
84577
  // src/app.jsx
84543
84578
  var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
84544
- var MINE = true ? "0.1.36" : "";
84579
+ var MINE = true ? "0.1.38" : "";
84545
84580
  var fmtDur = (s) => s < 60 ? `${Math.max(1, Math.round(s))}s` : `${Math.floor(s / 60)}m ${Math.round(s % 60)}s`;
84546
84581
  var plural = (n, w) => `${n} ${w}${n === 1 ? "" : "s"}`;
84547
84582
  var firstResp = (e) => e.first_response_s ? ` \xB7 first response ${e.first_response_s.toFixed(1)}s` : "";
@@ -85004,7 +85039,10 @@ function App2({ engine: engine2, task, resume, images = [] }) {
85004
85039
  question: ev.question || "",
85005
85040
  options: ev.options || [],
85006
85041
  default: ev.default || null,
85007
- questions: ev.questions || null
85042
+ questions: ev.questions || null,
85043
+ kind: ev.kind || null,
85044
+ summary: ev.summary || "",
85045
+ evidence: ev.evidence || []
85008
85046
  });
85009
85047
  setQStep(0);
85010
85048
  setQAnswers({});
@@ -85715,6 +85753,11 @@ function App2({ engine: engine2, task, resume, images = [] }) {
85715
85753
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { dimColor: true, children: spinnerLabel })
85716
85754
  ] }),
85717
85755
  question && step && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", borderStyle: "round", borderColor: ACCENT, paddingX: 1, marginTop: 1, children: [
85756
+ question.kind === "feedback" && qStep === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", marginBottom: 1, children: [
85757
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: ACCENT, bold: true, children: "\u2726 hum asks for your judgment" }) }),
85758
+ question.summary.split("\n").map((l, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: ` ${l}` }, `s${i}`)),
85759
+ question.evidence.map((e, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { dimColor: true, children: ` evidence: ${e}` }, `e${i}`))
85760
+ ] }) : null,
85718
85761
  step.header ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { dimColor: true, children: [
85719
85762
  " ",
85720
85763
  step.header
@@ -85738,8 +85781,8 @@ function App2({ engine: engine2, task, resume, images = [] }) {
85738
85781
  ] }, i)),
85739
85782
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { dimColor: true, children: [
85740
85783
  " ",
85741
- stepLabels.length ? step.multi ? "a number ticks \xB7 space ticks the one marked \xB7 " : "a number picks \xB7 " : "",
85742
- "type an answer",
85784
+ stepLabels.length ? step.multi ? "a number ticks \xB7 space ticks the one marked \xB7 " : step.graded ? "a number marks \xB7 words after it if you like \xB7 " : "a number picks \xB7 " : "",
85785
+ step.graded ? "" : "type an answer",
85743
85786
  step.default ? " \xB7 enter takes the default" : "",
85744
85787
  step.multi && stepLabels.length ? " \xB7 enter takes what is ticked" : "",
85745
85788
  step.secret ? " \xB7 it is not shown and not recorded" : ""
@@ -86000,7 +86043,7 @@ init_update();
86000
86043
  init_install();
86001
86044
  var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
86002
86045
  import { spawnSync as spawnSync5 } from "node:child_process";
86003
- var MINE2 = true ? "0.1.36" : "0.0.0";
86046
+ var MINE2 = true ? "0.1.38" : "0.0.0";
86004
86047
  var layout = installLayout();
86005
86048
  function completeInstall() {
86006
86049
  if (layout.kind !== "npm" || !needsInstall(MINE2)) return;
package/dist/install.mjs CHANGED
@@ -33,6 +33,20 @@ function installedVersion(env = process.env, runImpl = run) {
33
33
  }
34
34
  return v;
35
35
  }
36
+ function trustedPython(env = process.env, runImpl = run) {
37
+ if (!win) return null;
38
+ const r = runImpl("py", ["-3.12", "-I", "-c", "import ssl, sys; print(sys.executable)"]);
39
+ const p = r && r.status === 0 ? String(r.stdout).trim().split(/\r?\n/).pop() : "";
40
+ return /^[a-z]:\\.+\\python(w)?\.exe$/i.test(p) ? p : null;
41
+ }
42
+ var ASK_SSL = ["-I", "-c", "import ssl"];
43
+ function sslBlocked(env = process.env, runImpl = run) {
44
+ const r = runImpl(enginePython(env), ASK_SSL);
45
+ if (r && r.status === 0) return null;
46
+ const text = String(r && (r.stderr || r.stdout) || "ssl did not import").trim().split(/\r?\n/).filter(Boolean).pop() || "ssl did not import";
47
+ return text;
48
+ }
49
+ var sslAdvice = (env, version) => `the machine's application control blocked Python's OpenSSL DLL in ${engineDir(env)}; install Python 3.12 from python.org (Microsoft signs it), then run ${npmFix(version)}`;
36
50
  var readInstallState = (env = process.env) => {
37
51
  try {
38
52
  return JSON.parse(fs.readFileSync(statePath(env), "utf8"));
@@ -82,14 +96,23 @@ function installEngine(version, { env = process.env, say = (m) => console.log(`h
82
96
  fs.unlinkSync(stampPath(env));
83
97
  } catch {
84
98
  }
85
- if (!fs.existsSync(python)) {
86
- const args = ["venv", "--quiet", "--python", "3.12", ...fs.existsSync(dir) ? ["--clear"] : [], dir];
87
- if ((runImpl(u, args, { stdio: "inherit" }) || {}).status !== 0) return outcome(false, "uv venv failed");
88
- }
89
- if ((runImpl(u, ["pip", "install", "--quiet", "--python", python, spec], { stdio: "inherit" }) || {}).status !== 0) return outcome(false, `uv pip install ${spec} failed`);
90
- const got = importedVersion(env, runImpl);
99
+ const trusted = trustedPython(env, runImpl);
100
+ const makeVenv = (clear) => (runImpl(u, ["venv", "--quiet", "--python", trusted || "3.12", ...clear ? ["--clear"] : [], dir], { stdio: "inherit" }) || {}).status === 0;
101
+ const pipIn = () => (runImpl(u, ["pip", "install", "--quiet", "--python", python, spec], { stdio: "inherit" }) || {}).status === 0;
102
+ if (!fs.existsSync(python) && !makeVenv(fs.existsSync(dir))) return outcome(false, "uv venv failed");
103
+ if (!pipIn()) return outcome(false, `uv pip install ${spec} failed`);
104
+ let got = importedVersion(env, runImpl);
91
105
  if (!got) return outcome(false, "hum did not import after the install");
92
106
  if (got !== version && !env.HUM_ENGINE_SPEC) return outcome(false, `installed ${got}, wanted ${version}`, got);
107
+ let blocked = sslBlocked(env, runImpl);
108
+ if (blocked && trusted) {
109
+ say(`the policy here refuses the environment's OpenSSL (${blocked}); rebuilding it on ${trusted} \u2026`);
110
+ if (makeVenv(true) && pipIn()) {
111
+ got = importedVersion(env, runImpl) || got;
112
+ blocked = sslBlocked(env, runImpl);
113
+ }
114
+ }
115
+ if (blocked) return outcome(false, sslAdvice(env, version));
93
116
  fs.mkdirSync(dir, { recursive: true });
94
117
  fs.writeFileSync(stampPath(env), `${got}
95
118
  `);
@@ -105,6 +128,7 @@ function installEngine(version, { env = process.env, say = (m) => console.log(`h
105
128
  }
106
129
  }
107
130
  export {
131
+ ASK_SSL,
108
132
  ASK_VERSION,
109
133
  NPM_FIX,
110
134
  engineDir,
@@ -115,5 +139,8 @@ export {
115
139
  installedVersion,
116
140
  needsInstall,
117
141
  npmFix,
118
- readInstallState
142
+ readInstallState,
143
+ sslAdvice,
144
+ sslBlocked,
145
+ trustedPython
119
146
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metaphi-ai/hum",
3
- "version": "0.1.36",
3
+ "version": "0.1.38",
4
4
  "description": "Hum (हम): a self-improving coding agent for your terminal.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",