hypeframe 0.8.0 → 0.8.1

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/index.js +108 -46
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -102,30 +102,53 @@ function maskEmail(email) {
102
102
  }
103
103
 
104
104
  // src/config/settings.ts
105
- import fs3 from "node:fs";
105
+ import fs4 from "node:fs";
106
106
  import os2 from "node:os";
107
+
108
+ // src/util/which.ts
109
+ import fs3 from "node:fs";
110
+ import path2 from "node:path";
111
+ function isAndroid() {
112
+ return process.platform === "android" || !!process.env.TERMUX_VERSION || (process.env.PREFIX ?? "").includes("/com.termux/");
113
+ }
114
+ function onPath(name) {
115
+ if (!/^[\w.@+-]{1,80}$/.test(name))
116
+ return null;
117
+ const file = process.platform === "win32" ? /\.exe$/i.test(name) ? name : `${name}.exe` : name;
118
+ for (const dir of (process.env.PATH || "").split(path2.delimiter).filter(Boolean)) {
119
+ const f = path2.join(dir, file);
120
+ try {
121
+ const st = fs3.statSync(f);
122
+ if (st.isFile() && (process.platform === "win32" || st.mode & 73))
123
+ return f;
124
+ } catch {}
125
+ }
126
+ return null;
127
+ }
128
+
129
+ // src/config/settings.ts
107
130
  var DEFAULT_GATEWAY = "https://api.sairipedia.com";
108
131
  var DEFAULT_WEB = "https://hype-frame.com";
109
132
  function readSettings() {
110
133
  try {
111
- return JSON.parse(fs3.readFileSync(settingsFile(), "utf8"));
134
+ return JSON.parse(fs4.readFileSync(settingsFile(), "utf8"));
112
135
  } catch {
113
136
  return {};
114
137
  }
115
138
  }
116
139
  function saveSettings(s) {
117
140
  const f = settingsFile();
118
- fs3.writeFileSync(`${f}.tmp`, JSON.stringify({ ...readSettings(), ...s }, null, 2), { mode: 384 });
119
- fs3.renameSync(`${f}.tmp`, f);
141
+ fs4.writeFileSync(`${f}.tmp`, JSON.stringify({ ...readSettings(), ...s }, null, 2), { mode: 384 });
142
+ fs4.renameSync(`${f}.tmp`, f);
120
143
  }
121
- function resolveSettings(flags = {}) {
144
+ function resolveSettings(flags = {}, android = isAndroid()) {
122
145
  const s = readSettings();
123
146
  const clean = (u) => u.replace(/\/+$/, "");
124
147
  return {
125
148
  gateway: clean(flags.gateway || process.env.HYPEFRAME_GATEWAY_URL || s.gateway || DEFAULT_GATEWAY),
126
149
  web: clean(flags.web || process.env.HYPEFRAME_WEB_URL || s.web || DEFAULT_WEB),
127
150
  name: (flags.name || s.name || os2.hostname()).slice(0, 40),
128
- gpu: flags.gpu ?? s.gpu ?? false
151
+ gpu: android ? false : flags.gpu ?? s.gpu ?? false
129
152
  };
130
153
  }
131
154
  function osName() {
@@ -336,6 +359,7 @@ Tekan Esc untuk melewati satu langkah. Panduan ini bisa dibuka lagi dari Bantuan
336
359
  "doctor.ffmpegLater": "belum ada; diunduh otomatis saat mesin menyala",
337
360
  "doctor.alpha": "Klip transparan",
338
361
  "doctor.alphaNo": "tidak didukung Chrome ini; dibuat di server atau HP",
362
+ "doctor.tryChromiumMini": "Chromium Termux belum bisa render di HP ini. Coba Chromium di Linux mini: hypeframe chromium",
339
363
  "doctor.yes": "bisa",
340
364
  "doctor.no": "tidak bisa",
341
365
  "doctor.unreachable": "tidak terjangkau",
@@ -583,6 +607,7 @@ Press Esc to skip a step. You can open this guide again from Help & maintenance.
583
607
  "doctor.ffmpegLater": "not yet; downloaded automatically when the engine starts",
584
608
  "doctor.alpha": "Transparent clips",
585
609
  "doctor.alphaNo": "not supported by this Chrome; made on the server or phone",
610
+ "doctor.tryChromiumMini": "Termux's Chromium cannot render on this phone yet. Try Chromium in the Linux mini: hypeframe chromium",
586
611
  "doctor.yes": "yes",
587
612
  "doctor.no": "no",
588
613
  "doctor.unreachable": "unreachable",
@@ -647,8 +672,8 @@ function t(key, vars = {}) {
647
672
  }
648
673
 
649
674
  // src/ui/log.ts
650
- import fs4 from "node:fs";
651
- import path2 from "node:path";
675
+ import fs5 from "node:fs";
676
+ import path3 from "node:path";
652
677
 
653
678
  // src/ui/theme.ts
654
679
  import picocolors from "picocolors";
@@ -691,13 +716,13 @@ var MAX_FILE = 1024 * 1024;
691
716
  var fileReady = false;
692
717
  function toFile(line) {
693
718
  try {
694
- const f = path2.join(logDir(), "hypeframe.log");
719
+ const f = path3.join(logDir(), "hypeframe.log");
695
720
  if (!fileReady) {
696
721
  fileReady = true;
697
- if (fs4.existsSync(f) && fs4.statSync(f).size > MAX_FILE)
698
- fs4.renameSync(f, `${f}.1`);
722
+ if (fs5.existsSync(f) && fs5.statSync(f).size > MAX_FILE)
723
+ fs5.renameSync(f, `${f}.1`);
699
724
  }
700
- fs4.appendFileSync(f, `${new Date().toISOString()} ${line}
725
+ fs5.appendFileSync(f, `${new Date().toISOString()} ${line}
701
726
  `, { mode: 384 });
702
727
  } catch {}
703
728
  }
@@ -756,7 +781,7 @@ import path7 from "node:path";
756
781
  // package.json
757
782
  var package_default = {
758
783
  name: "hypeframe",
759
- version: "0.8.0",
784
+ version: "0.8.1",
760
785
  description: "Local engine for HypeFrame Web: code clips, video renders and AI agents run on your own machine; the web is just the view.",
761
786
  keywords: [
762
787
  "hypeframe",
@@ -824,14 +849,14 @@ You are running on the user's computer through the HypeFrame engine. The user ty
824
849
 
825
850
  // src/agent/registry.ts
826
851
  import { spawnSync } from "node:child_process";
827
- import fs5 from "node:fs";
852
+ import fs6 from "node:fs";
828
853
  var SUPPORTED_AGENTS = ["antigravity-acp", "codex-acp", "opencode"];
829
854
  var isSupported = (id) => SUPPORTED_AGENTS.includes(id);
830
855
  var OFFICIAL_REGISTRY = "https://cdn.agentclientprotocol.com/registry/v1/latest/registry.json";
831
856
  var registryUrl = () => process.env.HYPEFRAME_ACP_REGISTRY || OFFICIAL_REGISTRY;
832
857
  var isLocalRegistry = (u) => u.startsWith("file:") || /^http:\/\/127\.0\.0\.1[:/]/.test(u);
833
858
  function isMusl() {
834
- if (fs5.existsSync("/etc/alpine-release"))
859
+ if (fs6.existsSync("/etc/alpine-release"))
835
860
  return true;
836
861
  const r = spawnSync("ldd", ["--version"], { encoding: "utf8" });
837
862
  return /musl/i.test(`${r.stdout ?? ""}${r.stderr ?? ""}`);
@@ -848,7 +873,7 @@ function valid(a) {
848
873
  }
849
874
  async function fetchRegistry() {
850
875
  const u = registryUrl();
851
- const text = u.startsWith("file:") ? fs5.readFileSync(new URL(u), "utf8") : await (await fetch(u, { signal: AbortSignal.timeout(20000) })).text();
876
+ const text = u.startsWith("file:") ? fs6.readFileSync(new URL(u), "utf8") : await (await fetch(u, { signal: AbortSignal.timeout(20000) })).text();
852
877
  const j = JSON.parse(text);
853
878
  const local = isLocalRegistry(u);
854
879
  return (Array.isArray(j.agents) ? j.agents : []).filter(valid).map((a) => local ? a : { ...a, distribution: { ...a.distribution, local: undefined } });
@@ -859,29 +884,6 @@ import { spawnSync as spawnSync2 } from "node:child_process";
859
884
  import crypto from "node:crypto";
860
885
  import fs7 from "node:fs";
861
886
  import path4 from "node:path";
862
-
863
- // src/util/which.ts
864
- import fs6 from "node:fs";
865
- import path3 from "node:path";
866
- function isAndroid() {
867
- return process.platform === "android" || !!process.env.TERMUX_VERSION || (process.env.PREFIX ?? "").includes("/com.termux/");
868
- }
869
- function onPath(name) {
870
- if (!/^[\w.@+-]{1,80}$/.test(name))
871
- return null;
872
- const file = process.platform === "win32" ? /\.exe$/i.test(name) ? name : `${name}.exe` : name;
873
- for (const dir of (process.env.PATH || "").split(path3.delimiter).filter(Boolean)) {
874
- const f = path3.join(dir, file);
875
- try {
876
- const st = fs6.statSync(f);
877
- if (st.isFile() && (process.platform === "win32" || st.mode & 73))
878
- return f;
879
- } catch {}
880
- }
881
- return null;
882
- }
883
-
884
- // src/agent/linux.ts
885
887
  var DISTRO = "ubuntu";
886
888
  function linuxDir() {
887
889
  const d = path4.join(dataDir(), "linux");
@@ -2335,8 +2337,49 @@ import http from "node:http";
2335
2337
  import path10 from "node:path";
2336
2338
  import { Browser, detectBrowserPlatform, getInstalledBrowsers, install, resolveBuildId } from "@puppeteer/browsers";
2337
2339
  import puppeteer from "puppeteer-core";
2340
+ var ANDROID_ARGS = ["--no-sandbox", "--disable-dev-shm-usage"];
2341
+ var ANDROID_FALLBACKS = [[], ["--enable-features=NetworkServiceInProcess2"], ["--single-process", "--no-zygote"]];
2342
+ var flagsFile = () => path10.join(dataDir(), "chrome-flags.json");
2343
+ var sameFlags = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
2344
+ function savedFlags() {
2345
+ try {
2346
+ const a = JSON.parse(fs14.readFileSync(flagsFile(), "utf8")).args;
2347
+ return Array.isArray(a) && ANDROID_FALLBACKS.some((f) => sameFlags(f, a)) ? [...a] : [];
2348
+ } catch {
2349
+ return [];
2350
+ }
2351
+ }
2352
+ function saveFlags(a) {
2353
+ try {
2354
+ if (a.length)
2355
+ fs14.writeFileSync(flagsFile(), JSON.stringify({ args: a }));
2356
+ else
2357
+ fs14.rmSync(flagsFile(), { force: true });
2358
+ } catch {}
2359
+ }
2338
2360
  function chromePlatformArgs(android = isAndroid()) {
2339
- return android ? ["--no-sandbox"] : [];
2361
+ return android ? [...ANDROID_ARGS, ...savedFlags()] : [];
2362
+ }
2363
+ async function probeChrome(attempt, android = isAndroid()) {
2364
+ if (!android)
2365
+ return attempt([]);
2366
+ const saved = savedFlags();
2367
+ let first;
2368
+ for (const extra of [saved, ...ANDROID_FALLBACKS.filter((f) => !sameFlags(f, saved))]) {
2369
+ try {
2370
+ const r = await attempt([...extra]);
2371
+ if (!sameFlags(extra, saved))
2372
+ saveFlags(extra);
2373
+ return r;
2374
+ } catch (e) {
2375
+ first ??= e;
2376
+ }
2377
+ }
2378
+ throw first;
2379
+ }
2380
+ function chromeLogHint(log) {
2381
+ return log.split(`
2382
+ `).filter((l) => /:(ERROR|FATAL):|crash/i.test(l)).slice(-2).map((l) => l.replace(/^\[[^\]]*\]\s*/, "").trim().slice(0, 160)).join(" / ");
2340
2383
  }
2341
2384
  function candidates() {
2342
2385
  const e = process.env;
@@ -2348,10 +2391,12 @@ function candidates() {
2348
2391
  }
2349
2392
  return ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"].map((n) => onPath(n)).filter((p) => !!p);
2350
2393
  }
2351
- function findChrome() {
2394
+ function findChrome(android = isAndroid()) {
2352
2395
  const forced = process.env.HYPEFRAME_CHROME;
2353
2396
  if (forced)
2354
2397
  return fs14.existsSync(forced) ? forced : null;
2398
+ if (android && linuxChromiumReady())
2399
+ return chromiumWrapper();
2355
2400
  return candidates().find((p) => fs14.existsSync(p)) || null;
2356
2401
  }
2357
2402
  async function cachedChrome(cacheDir) {
@@ -2404,10 +2449,21 @@ var TRY_ENCODER = `async (c) => {
2404
2449
  setTimeout(() => ok(false), 10000);
2405
2450
  });
2406
2451
  }`;
2407
- async function checkChrome(chrome, { gpu = false } = {}) {
2452
+ async function checkChrome(chrome, { gpu = false, android = isAndroid() } = {}) {
2453
+ return probeChrome(async (extra) => ({ ...await checkOnce(chrome, gpu, android ? [...ANDROID_ARGS, ...extra] : []), extra }), android);
2454
+ }
2455
+ async function checkOnce(chrome, gpu, platformArgs) {
2408
2456
  const srv = http.createServer((_q, r) => (r.writeHead(200, { "content-type": "text/html" }), r.end("<!doctype html><title>check</title>")));
2409
2457
  await new Promise((ok) => srv.listen(0, "127.0.0.1", ok));
2410
- const b = await puppeteer.launch({ executablePath: chrome, headless: true, protocolTimeout: 60000, args: ["--no-first-run", "--disable-extensions", ...gpu ? [] : softwareGpuArgs, ...chromePlatformArgs()] });
2458
+ let b;
2459
+ try {
2460
+ b = await puppeteer.launch({ executablePath: chrome, headless: true, protocolTimeout: 60000, args: ["--no-first-run", "--disable-extensions", ...gpu ? [] : softwareGpuArgs, ...platformArgs] });
2461
+ } catch (e) {
2462
+ srv.close();
2463
+ throw e;
2464
+ }
2465
+ let log = "";
2466
+ b.process()?.stderr?.on("data", (d) => log = (log + d).slice(-8000));
2411
2467
  try {
2412
2468
  const p = await b.newPage();
2413
2469
  await p.goto(`http://127.0.0.1:${srv.address().port}/`);
@@ -2417,6 +2473,9 @@ async function checkChrome(chrome, { gpu = false } = {}) {
2417
2473
  avc: await attempt({ codec: "avc1.42001f", width: 320, height: 568, bitrate: 1e6, framerate: 30 }),
2418
2474
  transparent: await attempt({ codec: "vp09.00.10.08", width: 320, height: 568, bitrate: 1e6, framerate: 30, alpha: "keep" })
2419
2475
  };
2476
+ } catch (e) {
2477
+ const hint = chromeLogHint(log);
2478
+ throw hint ? new Error(`${e.message} · Chrome: ${hint}`) : e;
2420
2479
  } finally {
2421
2480
  await b.close().catch(() => {
2422
2481
  return;
@@ -4362,7 +4421,7 @@ async function config(args) {
4362
4421
  const name = await p2.text({ message: t("config.name"), initialValue: s.name, validate: (v) => v && v.trim() ? undefined : "—" });
4363
4422
  if (p2.isCancel(name))
4364
4423
  return;
4365
- const gpu = await p2.confirm({ message: t("config.gpu"), initialValue: s.gpu });
4424
+ const gpu = isAndroid() ? false : await p2.confirm({ message: t("config.gpu"), initialValue: s.gpu });
4366
4425
  if (p2.isCancel(gpu))
4367
4426
  return;
4368
4427
  const language = await p2.select({
@@ -4438,11 +4497,14 @@ async function doctor(args) {
4438
4497
  else {
4439
4498
  try {
4440
4499
  const info = await checkChrome(chrome, { gpu: s.gpu });
4441
- show({ label: "Chrome", result: info.avc ? "ok" : "error", detail: `${info.version} ${color.muted(icon.dot)} H.264 ${info.avc ? t("doctor.yes") : t("doctor.no")}` });
4500
+ const extra = info.extra?.length ? ` ${color.muted(`${icon.dot} ${info.extra.join(" ")}`)}` : "";
4501
+ show({ label: "Chrome", result: info.avc ? "ok" : "error", detail: `${info.version} ${color.muted(icon.dot)} H.264 ${info.avc ? t("doctor.yes") : t("doctor.no")}${extra}` });
4442
4502
  show({ label: t("doctor.alpha"), result: info.transparent ? "ok" : "warn", detail: info.transparent ? t("doctor.yes") : t("doctor.alphaNo") });
4443
4503
  } catch (e) {
4444
4504
  show({ label: "Chrome", result: "error", detail: String(e.message).split(`
4445
- `)[0].slice(0, 120) });
4505
+ `)[0].slice(0, 280) });
4506
+ if (isAndroid() && !linuxChromiumReady())
4507
+ show({ label: "Chromium", result: "warn", detail: t("doctor.tryChromiumMini") });
4446
4508
  }
4447
4509
  }
4448
4510
  const gw = await reach(`${s.gateway}/`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypeframe",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Local engine for HypeFrame Web: code clips, video renders and AI agents run on your own machine; the web is just the view.",
5
5
  "keywords": [
6
6
  "hypeframe",